from pydantic import BaseModel, Field
from typing import List, Optional

class BaseContent(BaseModel):
    title: str = Field(..., description="标题")
    order: Optional[int] = Field(0, description="排序")
    type: Optional[int] = Field(1, description="类型1图文2视频")
    cover: Optional[str] = Field("", description="封面")
    tags: Optional[str] = Field("", description="标签")
    files: Optional[str] = Field("", description="多文件")
    go_type: Optional[int] = Field(0, description="跳转类型")
    go_url: Optional[str] = Field(0, description="跳转值")
    desc: Optional[str] = Field("", description="备注")
    parent: Optional[int] = Field(0, description="分类id")
    shop_ids: Optional[str] = Field("", description="关联商品")
    state: Optional[bool] = True


class ContentCreate(BaseContent):
    files:Optional[list]= None
    tags:Optional[list]= None


class ContentUpdate(BaseContent):
    id: int
    files: Optional[list]= None
    tags: Optional[list]= None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})



class BaseContentCategory(BaseModel):
    name: str = Field(..., description="分类名称", example="活动素材")
    desc: Optional[str] = Field("", description="备注", example="活动素材")
    order: int = Field(0, description="排序")
    parent_id: int = Field(0, description="父分类ID")


class ContentCategoryCreate(BaseContentCategory):
    ...


class ContentCategoryUpdate(BaseContentCategory):
    id: int

    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})
